package com.yj.apiback.controller;

import com.yj.apiback.result.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.constraints.Min;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/goods")
public class GoodsController {

    //session详情
    @GetMapping("/list")
    @ResponseBody
    public Result list() {
        Map<String, String> data = new HashMap<String, String>();
        data.put("msg", "this is goods list page");
        return Result.success(data);
    }

    @GetMapping("/detail")
    @ResponseBody
    public Result detail(@Min(value = 1,message = "商品id需要>0")@RequestParam("goodsId") Long goodsId) {
        Map<String, String> data = new HashMap<String, String>();
        data.put("goodsName", "商品"+String.valueOf(goodsId));
        data.put("goodsId", String.valueOf(goodsId));
        return Result.success(data);
    }

}